﻿using NLog;
using System;
using System.Reflection.Metadata;

namespace ExceptionNLogDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            //var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
            //var logger LogManager.LoadConfiguration("nlog.config").GetCurrentClassLogger();
            var logger = LogManager.GetCurrentClassLogger();
            try
            {
                logger.Info("NLog Launching...");

                logger.Warn("NLog 警告...");

                logger.Error("NLog 错误...");
            }
            catch (Exception exception)
            {
                //Console.WriteLine($"Stopped program because of exception : {exception.Message}{exception.StackTrace}");

                logger.Error(exception, "Stopped program because of exception", exception);
                //throw;
            }
            finally
            {
                NLog.LogManager.Shutdown();
            }
        }
    }
}
